-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pangrams.c
59 lines (58 loc) · 1.51 KB
/
Pangrams.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @Repository HackerRank Soulutions
* @file Pangrams
* @author Abdelrahman Ahmed Moussa ([email protected])
* @copyright Copyright (c) 2024
*
*/
/*------------------------------------------------------------------------------*/
/* */
/* I didn't used any functions from <string.h> */
/* */
/*------------------------------------------------------------------------------*/
char* pangrams(char* s)
{
int alpha[(('z'-'a')+1)]={0};
/*
very important note :
we will assign letteral string to this pointer to char
that means that we assign to it an address from .rodata section
so, it is not needed to make is static
*/
char *string=((void*)0);
int i=0,j;
//char ch;
char flag=1;
while (s[i]!='\0')
{
if (s[i]>='a'&&s[i]<='z')
{
//ch=s[i];
//alpha[ch-'a']++;
alpha[s[i]-'a']++;
}
else if (s[i]>='A'&&s[i]<='Z')
{
//ch=(s[i]-'A')+'a';
//alpha[ch-'a']++;
alpha[s[i]-'A']++;
}
i++;
}
for (j=0; (j<(('z'-'a')+1)) && (flag==1) ; j++)
{
if (alpha[j]==0)
{
flag=0;
}
}
if (flag==0)
{
string="not pangram";
}
else
{
string="pangram";
}
return string;
}